package com.lxl.workbench.service.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.commons.mapper.impl.BookCategoryMapperImpl;
import com.lxl.commons.mapper.impl.CategoryMapperImpl;
import com.lxl.workbench.dao.CategoryDao;
import com.lxl.workbench.dao.CategoryDaoImpl;
import com.lxl.workbench.entity.Category;
import com.lxl.workbench.service.CategoryService;

import java.sql.SQLException;
import java.util.List;

/**
 * @author 北上寻海
 */
public class CategoryServiceImpl implements CategoryService {
    CategoryDao categoryDao = new CategoryDaoImpl();
    IMapper bookCategoryMapper = new BookCategoryMapperImpl();
    IMapper categoryMapper = new CategoryMapperImpl();
    @Override
    public List<Category> queryBookCategoryFuzzy(String bookCategory) throws SQLException {
        return bookCategoryMapper.mapper(categoryDao.selectBookCategory(bookCategory));
    }

    @Override
    public void deleteCategoryByIds(String[] delIds) throws SQLException {
            categoryDao.deleteCategoryByIds(delIds);
    }

    @Override
    public int addCategoryByCondition(Category category) throws SQLException {
        return categoryDao.addCategoryByCondition(category);
    }

    @Override
    public List<Category> selectCategoryId(String bookType) throws SQLException {
        return categoryMapper.mapper(categoryDao.selectCategoryId(bookType));
    }
}
